class Solution {
public:
	vector<vector<int>> levelOrder(TreeNode* root) {
		vector<vector<int>> answer;
		queue<TreeNode*>q;
		q.push(root);
		if (root == NULL) { return answer; }

		while (!q.empty()) {
			vector<int>temp;
			int len=q.size();
			for (int i = 0; i < len; i++) {
				root = q.front();
				q.pop();
				temp.push_back(root->val);
				if (root->left) { q.push(root->left); }
				if (root->right) { q.push(root->right); }
			}
			answer.push_back(temp);
		}
		return answer;
	}
};